;
; wvdChar.asm
;
; wvdChar(WINDOW *wptr,row,col,token)
;
; WINDOW *wptr pointer to window structure
; int row      row of string write
; int col      column of string write
; int token    char + 256*attr
;

;--------------------------------------
;
; include defs, prototypes and macros
;

include tab6.inc

;--------------------------------------
;
; begin code segment
;

	.CODE

wvdChar PROC PASCAL PUBLIC USES ds es di si bx,wptr:Ptr Window,prow:BYTE,pcol:BYTE,pchar:BYTE,pattr:BYTE
        LOCAL   ur:Byte,uc:Byte
;
; relocate Window structure data to locals
   IF mdl eq 1
        mov     bx,wptr
   ELSE
        lds     bx,wptr
   ENDIF

        mov     al,(WINDOW Ptr [bx]).ur ; relocate upper row
        mov     ur,al
        mov     al,(WINDOW Ptr [bx]).uc ; relocate upper col
        mov     uc,al

 IF mdl eq 3	
	push	ds
	mov	ax,SEG scrn_seg
	mov	ds,ax
	mov	ax,ds:scrn_seg
	mov	es,ax
	pop	ds
 ELSE
	mov	ax,scrn_seg
	mov	es,ax
 ENDIF

	xor	ax,ax         ; 0 -> ax
	mov	al,prow       ; row -> al
        add     al,ur         ; adjust for window global coord.
	mov	bl,160        ; 80 chars wide * 2
	mul	bl            ; row * scrn width  -> ax
	mov	cl,pcol       ; column to cl
        add     cl,uc         ; adjust for window global coord.
	xor	ch,ch         ; 0 -> ch
	shl	cx,1          ; col * 2
	add	ax,cx         ; column + (row * scrn width)
	mov	di,ax         ; point di to scrn
	mov	al,pchar      ; token to ax
	mov	ah,pattr
	stosw                  ; ax -> screen
	ret
wvdChar	ENDP

	END
	
	

